﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Projekt.Models.Primitives
{
    public class Net
    {
        VertexPositionColor[] vertices;
        private GraphicsDevice graphicsDevice;
        BasicEffect basicEffect;

        public Net(GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;

            vertices = new VertexPositionColor[1200];
            for (int i = 0; i < 300; i=i+2)
            {
                vertices[i].Position = new Vector3(10000,0, -20000 + (i * 100));
                vertices[i].Color = Color.AntiqueWhite;
                vertices[i + 1].Position = new Vector3(-10000, 0, -20000 + (i * 100));
                vertices[i+1].Color = Color.AntiqueWhite;
            }
            for (int i = 600; i < 900; i = i + 2)
            {
                vertices[i].Position = new Vector3(-20000 + ((i-600) * 100), 0, 10000);
                vertices[i].Color = Color.AntiqueWhite;
                vertices[i + 1].Position = new Vector3(-20000 + ((i-600) * 100), 0, -10000);
                vertices[i + 1].Color = Color.AntiqueWhite;
            }  

            basicEffect = new BasicEffect(graphicsDevice);
            basicEffect.VertexColorEnabled = true;
        }

        public void Draw(Matrix View, Matrix Projection)
        {
            basicEffect.Projection = Projection;
            basicEffect.View = View;

            basicEffect.CurrentTechnique.Passes[0].Apply();

            graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 300, 600);
        }
    }
}
